#include <cstdio>
long long s[60000];
int n,m;
int main()
{
    freopen("C.in","r",stdin);
    while (~scanf("%d %d", &n, &m)) {
                memset(f, 0, sizeof(f));
                f[0] = 1;
                x = z = 0;\
                ans = 0;
                while (n--) {
                        scanf("%d", &y);
                        x = (x + y) % m;
                        f[x]++;
                        if (x > z)      z = x;
                }
                for (int i = 0; i <= z; i++)
                        if (f[i])       ans += f[i] * (f[i] - 1) / 2LL;
                //printf("%I64d\n", ans);
                printf("%lld\n", ans);
    }
    return 0;
}
